home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 5.6 KB | 203 lines | [TEXT/CWIE] |
- // Release Version: $ ODF 1 $
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
-
- //=======================================================================
- #ifndef PART_H
- #include "Part.h"
- #endif
-
- #ifndef CONTENT_H
- #include "Content.h"
- #endif
-
- #ifndef FRAME_H
- #include "Frame.h"
- #endif
-
- #ifndef COMMANDS_H
- #include "Commands.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k" // command numbers
- #endif
-
- // ----- Framework Layer -----
- #ifndef FWCONTXT_H
- #include "FWContxt.h" // FW_CViewContext
- #endif
-
- #ifndef FWPRHDLR_H
- #include "FWPrHdlr.h" // FW_CPrintHandler
- #endif
-
- // ----- OS Layer -----
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h" // FW_CSharedLibraryResourceFile, FW_gInstance
- #endif
-
- #ifndef FWMENU_H
- #include "FWMenu.h" // FW_CMenuBar, etc.
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h" // FW_CMenuEvent, FW_CMouseEvent
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h" // FW_CRectShape
- #endif
-
- #ifndef FWPICSHP_H
- #include "FWPicShp.h" // FW_PPicture, FW_CPictureShape
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h" // FW_CRoundRectShape
- #endif
-
- #ifndef FWCMD_H
- #include "FWCmd.h" // FW_CCommand
- #endif
-
- #include "FWFileSp.h"
- #include "FWFileOp.h"
-
- //========================================================================================
- #ifdef FW_BUILD_MAC
- #pragma segment Graphics3D
- #endif
-
- FW_DEFINE_AUTO(CGraphics3DFrame)
-
- //========================================================================================
- CGraphics3DFrame::CGraphics3DFrame(Environment* ev, ODFrame* odFrame,
- FW_CPresentation* presentation,
- CGraphics3DContent* content)
- : FW_CFrame(ev, odFrame, presentation, content->GetPart(ev)),
- fViewer(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- CGraphics3DFrame::~CGraphics3DFrame()
- {
- ::Q3ViewerDispose(fViewer);
- }
-
- //----------------------------------------------------------------------------------------
- void
- CGraphics3DFrame::FacetAdded(Environment* ev, ODFacet* facet, unsigned short facetCount)
- {
- FW_CFrame::FacetAdded(ev, facet, facetCount);
- ODPlatformWindow windowPtr = this->GetWindow(ev)->GetPlatformWindow(ev);
- // Get rectangle enclosing the window’s content region.
- Rect myRect = windowPtr->portRect;
- // Create a new viewer object in entire content region
- fViewer = ::Q3ViewerNew((CGrafPtr)windowPtr, &myRect, kQ3ViewerDefault);
- FW_CRect frameRect = this->GetBounds(ev);
-
- /* FW_CAcquiredODTransform tForm = facet->AcquireExternalTransform(ev, facet->GetCanvas(ev));
- ODPoint odPt;
- tForm->GetOffset(ev, &odPt);
- FW_CPoint fwPt(odPt);
- frameRect.Offset(fwPt.x, fwPt.y);
- */
- Rect r = frameRect.AsPlatformRect();
- short anErr = Q3ViewerSetBounds(fViewer, &r);
- }
-
- //----------------------------------------------------------------------------------------
- void
- CGraphics3DFrame::FrameShapeChanged(Environment* ev)
- {
- FW_CFrame::FrameShapeChanged(ev);
- FW_CRect frameRect = this->GetBounds(ev); // Get new frame rect
- Rect r = frameRect.AsPlatformRect();
- short anErr = ::Q3ViewerSetBounds(fViewer, &r);
- this->Invalidate(ev, frameRect);
- }
-
- //----------------------------------------------------------------------------------------
- void
- CGraphics3DFrame::Draw(Environment *ev, ODFacet* odFacet, ODShape* invalidShape) // Override
- {
- FW_CPlatformGraphicContext pc(ev, odFacet, invalidShape);
- FW_CRect frameRect = this->GetBounds(ev); // Get new frame rect
- Rect r = frameRect.AsPlatformRect();
- short anErr = ::Q3ViewerSetBounds(fViewer, &r);
-
- ::Q3ViewerDraw(fViewer);
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CGraphics3DFrame::DoMouseDown(Environment* ev, const FW_CMouseEvent& theMouseEvent)
- {
- FW_UNUSED(ev);
- ODEventData* eventRec = ((FW_CMouseEvent)theMouseEvent).GetPlatformEvent();
- FW_Boolean aBool = ::Q3ViewerEvent(fViewer, eventRec);
- return TRUE;
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CGraphics3DFrame::DoAdjustMenus(Environment* ev, FW_CMenuBar* menuBar, FW_Boolean hasMenuFocus,
- FW_Boolean isRoot) // Override
- {
- if (hasMenuFocus) {
- menuBar->EnableCommand(ev, cOpenFileCmdID, TRUE);
- }
- return false;
- }
-
- //----------------------------------------------------------------------------------------
- FW_Boolean
- CGraphics3DFrame::DoMenu(Environment* ev, const FW_CMenuEvent& theMenuEvent) // Override
- {
- FW_Boolean menuHandled = true;
- switch (theMenuEvent.GetCommandID(ev)) {
- case cOpenFileCmdID:
- OSType fileType = '3DMF';
- FW_COpenFileParameters openFileParam(&fileType, nil);
- FW_OFileSpecification* fileSpec = FW_CChooseFile::ChooseFileToOpen(openFileParam);
- FSSpec macSpec;
- fileSpec->MacGetFSSpec(ev, &macSpec);
- short refNum;
- short anErr = FSpOpenDF(&macSpec, fsCurPerm, &refNum);
- anErr = ::Q3ViewerUseFile(fViewer, refNum);
- this->FrameShapeChanged(ev);
- // FW_CRect frameRect = this->GetBounds(ev);
- // this->Invalidate(ev, frameRect);
- break;
-
- default:
- menuHandled = false;
- }
- return menuHandled;
- }
-
- //------------------------------------------------------------------------------
- FW_CPrintHandler*
- CGraphics3DFrame::NewPrintHandler(Environment* ev)
- {
- FW_CPart* part = GetPart(ev);
- return new FW_CPrintHandler(part, this);
- }
-
- //------------------------------------------------------------------------------
- FW_Boolean
- CGraphics3DFrame::IsCurrentlyPrintable(Environment* ev) const
- {
- return TRUE;
- }
-
- //------------------------------------------------------------------------------
- void
- CGraphics3DFrame::GetPrintContentExtent(Environment *ev, FW_CPoint& extent) const
- {
- FW_CRect frameRect = this->GetBounds(ev);
- extent = frameRect.Size();
- }
-
-